<template>
  <div>
    <page-list
      :url="url"
      :params="params"
      :needSearch="false"
      @initList="_initList"
      ref="pageList"
    >
      <van-cell
        class="card"
        v-for="(item, index) in list"
        :key="index"
      >
        <div @click="openDetail(item.CTCode)">
         <div class="warn_header">
                <div>{{ index + 1 }}、{{ item.TypeName }}</div>
              </div>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img class="iconimg"
                    style="vertical-align: middle"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />器材编号：{{ item.No }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img class="iconimg"
                    style="vertical-align: middle"
                    src="@/assets/Images/AppIcon/icon_list_org.png"
                    alt=""
                  />所属部门：{{ item.OrgName }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img class="iconimg"
                    style="vertical-align: middle"
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />位置：{{ item.Location }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img class="iconimg"
                    style="vertical-align: middle"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />点检条目：{{ item.CheckListDetailItem }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img class="iconimg"
                    style="vertical-align: middle"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />隐患描述：{{ item.HiddenDangerDesc }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <van-field
                    label="隐患图片"
                    readonly
                  >
                    <template #input>
                      <eagle-image-preview :images="item.Attachs">
                      </eagle-image-preview>
                    </template>
                  </van-field>
                </eagle-col>
              </eagle-row>
              <eagle-divider />
              <eagle-button
                class="ml-10 mb-10"
                style="float: right;height:30px;"
                size="small"
                type="default"
                v-if="item.Status == 10"
                @click.stop="siteCheck(item)"
              >整改
              </eagle-button>
              <eagle-button
                class="ml-10 mb-10"
                style="float: right; height: 30px"
                size="small"
                type="default"
                v-if="item.Status == 5 && item.CreateUserNamey
                 == user.UserName"
                @click.stop="siteVertify(item)"
                >验收
              </eagle-button>
              <!-- <eagle-button
                class="ml-10 mt-10"
                style="float: right;height:30px;"
                size="small"
                type="default"
                @click.stop="siteDetail(item)"
                >详情
              </eagle-button> -->
        </div>
      </van-cell>
    <!-- 弹出层 -->

    </page-list>
    <eagle-dialog
      title="整改"
      v-model="showCheck"
      titlePosition="center"
      @close="cancle"
      @confirm="confirm"
    >
      <eagle-input
        label="整改图片："
        name="uploader"
        v-model="VerifyAttachs"
        :key="ImgKey"
        ref="upload"
      >
        <template #input>
          <eagle-image-uploader :images.sync="VerifyAttachs"></eagle-image-uploader>
        </template>
      </eagle-input>
      <eagle-input
        label="整改说明"
        name="name"
        v-model="VerifyRemarks"
        placeholder="请输入"
        isInputText
        type="textarea"
        autosize
        row="3"
      ></eagle-input>
    </eagle-dialog>
    <eagle-dialog
      title="验收"
      v-model="showVertify"
      titlePosition="center"
      @close="cancle"
      @confirm="confirmVertify"
    >
      <eagle-radio-group
        name="radio"
        label="是否整改完成"
        v-model="Verify"
        direction="horizontal"
        required
      >
        <eagle-radio name="100">
          <span style="font-size: 14px">是</span>
        </eagle-radio>
        <eagle-radio name=-5>
          <span style="font-size: 14px">否</span>
        </eagle-radio>
      </eagle-radio-group>
    </eagle-dialog>
  </div>
</template>

<script>
import PageList from "../SiteFireEquipment/PageList.vue";
import { getMenuByMenuCode } from "@/api/common";
import FileListReadOnly from "../../../components/Attach/FileListReadOnlyYat.vue";
import store from "@/store/index";
import { getUserInfo } from "@/api/base";
export default {
  components: { PageList,FileListReadOnly },
  data() {
    return {
      showCheck: false,
      showVertify: false,
      IDS: "",
      ImgKey: "",
      Verify:"",
      VerifyRemarks: "",
      VerifyAttachs: "",
      rightValue: 0,
      url: '/SiteCheckTask/GetPageData',
      list: [],
      params: {
        
            // dataType: "ExceptHis",
            dataType: "ExceptHis",
            objCode: this.$route.query.objCode,
            keywords: "",
          },
      user: {},
    };
  },
  created() {
    // this.getMenuByMenuCode();
    if(process.env.VUE_APP_PLANTFORM&&process.env.VUE_APP_PLANTFORM=="CY"){
      store.state.title="专项清单[异常]"
    }
  },
  methods: {
    _initList(list) {
      console.log(list)
      this.list = list;
    },
    //详情
    openDetail(CTCode) {
      this.$router.push({
        path: "/SiteFireEquipmentCheck",
        query: { ctCode: CTCode },
      });
    },

    siteCheck(item) {
      this.IDS = item.ID;
      this.showCheck = true;
    },
    // 弹窗保存
    confirm() {
      let params = {
        IDS: this.IDS,
        VerifyAttachs: this.VerifyAttachs,
        VerifyRemarks: this.VerifyRemarks,
      };
      let _this = this;
      _this.$axios.post("/SiteCheckTask/ConfirmVerify", params).then((res) => {
        _this.$toast.success("保存成功");
        _this.showCheck = false;
        setTimeout(() => {
          this.$router.go(0)
        }, 300);
      });
    },
    cancle() {
      //this.ImgKey = "";
      this.VerifyAttachs = "";
      this.VerifyRemarks = "";
      this.showCheck = false;
      this.showVertify=false;
    },

    _fileUploadCb(attachs) {
			this.data.Attachs = attachs;
		},
    // getMenuByMenuCode() {
    //   var me = this;
    //   getMenuByMenuCode("GxInterviewRecord_List").then((res) => {
    //     me.rightValue = res.data ? res.data.RoleRightValue : 0;
    //   });
    // },
    siteVertify(item) {
      this.IDS = item.ID;
      this.showVertify = true;
    },
    confirmVertify(){
      let params ={
        IDS:this.IDS,
        Status:this.Verify
      };
      let _this = this;
      _this.$axios.post("/SiteCheckTask/AcceptanceCheck", params).then((res) => {
        _this.$toast.success("保存成功");
        _this.showVertify = false;
        setTimeout(() => {
          _this.$refs.eaglelist.getList();
        }, 300);
      });
    
    },
  },
};
</script>
<style lang="less" scoped>
.dep_btm {
  display: flex;
  justify-content: flex-end;
  line-height: 27px;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.icon {
  vertical-align:middle;
}
  .iconimg {
    height: 17px;
    width: 17px;
    margin-right: 5px;
    vertical-align:middle;
  }
</style>
